﻿using Shared.Const.Enum.Oss;

namespace Basic.Oss.Interfaces;

public interface IAliOssClient
{
    /// <summary>
    /// 普通上传文件
    /// </summary>
    /// <param name="objectName">oss存储对象key</param>
    /// <param name="content"></param>
    /// <param name="bucketName">存储空间名称</param>
    /// <returns></returns>
    PutObjectResult PutObjectCommon(string objectName, byte[] content, string bucketName = OssConstData.DefaultBucketName);

    /// <summary>
    /// 给文件名加oss上传目录
    /// </summary>
    /// <param name="filename"></param>
    /// <param name="dir"></param>
    /// <returns></returns>
    string GetOssFileName(string filename, EnumOssDir dir = EnumOssDir.RootDir);

    /// <summary>
    /// 签名(通过签名url)上传文件
    /// </summary>
    /// <param name="objectName">oss存储对象key</param>
    /// <param name="content"></param>
    /// <param name="bucketName">存储空间名称</param>
    /// <returns></returns>
    string PutObjectSignature(string objectName, byte[] content, string bucketName = OssConstData.DefaultBucketName);

    /// <summary>
    /// 根据objectName获取对应资源的签名url
    /// </summary>
    /// <param name="objectName">oss存储对象key</param>
    /// <param name="bucketName">存储空间名称</param>
    /// <returns></returns>
    string GetSignatureUrl(string objectName, string bucketName = OssConstData.DefaultBucketName);

    /// <summary>
    /// 根据objectName下载对应的资源
    /// </summary>
    /// <param name="objectName">oss存储对象key</param>
    /// <param name="bucketName">存储空间名称</param>
    /// <returns></returns>
    Task<byte[]> DownloadFile(string objectName, string bucketName = OssConstData.DefaultBucketName);

    /// <summary>
    /// 删除指定文件
    /// </summary>
    /// <param name="objectName">oss存储对象key</param>
    /// <param name="bucketName">存储空间名称</param>
    /// <returns></returns>
    bool DeleteFile(string objectName, string bucketName = OssConstData.DefaultBucketName);


    #region Stream

    /// <summary>
    /// 普通上传文件
    /// </summary>
    /// <param name="objectName">oss存储对象key</param>
    /// <param name="content"></param>
    /// <param name="bucketName">存储空间名称</param>
    /// <returns></returns>
    PutObjectResult PutObjectStream(string objectName, Stream content, string bucketName = OssConstData.DefaultBucketName);

    /// <summary>
    /// 签名(通过签名url)上传文件
    /// </summary>
    /// <param name="objectName">oss存储对象key</param>
    /// <param name="content"></param>
    /// <param name="bucketName">存储空间名称</param>
    /// <returns></returns>
    string PutObjectSignature(string objectName, Stream content, string bucketName = OssConstData.DefaultBucketName);

    /// <summary>
    /// 根据objectName下载对应的资源
    /// </summary>
    /// <param name="objectName">oss存储对象key</param>
    /// <param name="bucketName">存储空间名称</param>
    /// <returns></returns>
    Task<Stream> DownloadFileStream(string objectName, string bucketName = OssConstData.DefaultBucketName);

    #endregion

}
